<template>
	<view class="page" :style="themeColor">
		<view class="flex benben-position-layout flex flex-wrap align-center platformMessage_flex_0"
			:style="{height:(64+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx'}">
			<view class='flex flex-wrap align-center justify-between flex-sub platformMessage_fd0_0'>
				<view class='flex flex-wrap align-center platformMessage_fd0_0_c0' @tap.stop="handleJumpDiy"
					data-type="back" data-url="1">
					<text class='fu-iconfont2  platformMessage_fd0_0_c0_c0'>&#xE794;</text>
				</view>
				<view class='flex flex-wrap align-stretch justify-center'>
					<text class='platformMessage_fd0_0_c1_c0'>测评报告</text>
				</view>
				<view class='flex flex-wrap align-center platformMessage_fd0_0_c0'></view>
			</view>

		</view>
		<view :style="{height: (64+StatusBarRpx)+'rpx'}"></view>
		<view class="loading_css" v-if="isShow">
			<uv-loading-icon size="24" mode="circle" color="#4087FD" :show="true"></uv-loading-icon>
			<view>加载中</view>
		</view>

		<view class="result_bg" v-else>
			<view class="result_title">
				<image :src='STATIC_URL+"113.png"' mode=""></image>
				<text class="result_title_text">智海马科技测试结果</text>
				<image :src='STATIC_URL+"114.png"' mode=""></image>
			</view>
			<view class="result_name">
				<view class="result_name_1">
					<text class="result_name_1_1">姓名</text>
					<text>{{resultInfo.nickname}}</text>
				</view>
				<view class="result_name_2"></view>
				<view class="result_name_1">
					<text class="result_name_1_1">电话</text>
					<text>{{resultInfo.mobile}}</text>
				</view>
			</view>
			<view class="result_score">
				<view class="score_1">{{resultInfo.corresponding_num}}</view>
				<view class="score_2">词</view>
			</view>
			<view class="result_tips_1">经智海马科技测试您的词汇量约为</view>
			<view class="result_tips_2">
				<text class="stage_1">基本处于</text>
				<text class="stage_2">{{resultInfo.learning_stage}}</text>
				<text class="stage_3">阶段</text>
			</view>
			<view class="statistics">
				<view class="test_title">
					<view class="test_title_img">
						<image :src='STATIC_URL+"2.png"' mode=""></image>
					</view>
					<view class="test_title_view">
						<view class="test_title_view_1">测试结果</view>
						<view class="test_title_view_2">测评时间：{{resultInfo.create_time}}</view>
					</view>
				</view>
				<view class="charts-box">
					<qiun-data-charts type="pie" :opts="opts" :chartData="chartData" />
				</view>
			</view>
		</view>
	</view>
	</view>
</template>
<script>
	export default {
		components: {},

		data() {
			return {
				"cate_id": "",  // 阶段id
				"answer_num": 0,  // 当前阶段答对的题目数量
				"isShow": true,
				"resultInfo": {},  // 检测结果数据
				"statistics": [],  // 接口返回的饼状图数据
				chartData: {},
				opts: {
					color: ["#1890FF", "#91CB74", "#EE6666", "#FAC858", "#73C0DE", "#3CA272", "#FC8452", "#9A60B4","#ea7ccc"
					],
					padding: [5, 5, 5, 5],
					enableScroll: false,
					extra: {
						pie: {
							activeOpacity: 0.5,
							activeRadius: 10,
							offsetAngle: 0,
							labelWidth: 15,
							border: false,
							borderWidth: 3,
							borderColor: "#FFFFFF",
							customRadius: 150
						}
					}
				}
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},

		},
		watch: {},
		onLoad(options) {
			let {cate_id, answer_num} = options;
			if (cate_id !== undefined) this.cate_id = cate_id;
			if (answer_num !== undefined) this.answer_num = answer_num;
			this.getResult();
		},
		onUnload() {

		},
		onReady() {
			
		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		// 下拉刷新
		onPullDownRefresh() {
			
		},
		// 上拉加载
		onReachBottom() {
			
		},
		onPageScroll(e) {

		},
		methods: {
			// 获取检测结果  post65e570c7b0376
			getResult() {
				this.$api.post(global.apiUrls.post65e570c7b0376, {
					cate_id: this.cate_id,
					answer_num: this.answer_num
				}).then(res => {
					// console.log(res);
					this.isShow = false;
					if (res.data.code == 1) {
						this.resultInfo = res.data.data;
						this.statistics = res.data.data.statistics;
						if (this.statistics.length > 0) {
							this.statistics.forEach((v, k) => {
								v.value = Number(v.value);
							})
						}
						this.getServerData();
					} else {
						this.$message.info(res.data.msg);
					}
				})
			},
			getServerData() {
				setTimeout(() => {
					//模拟服务器返回数据，如果数据格式和标准格式不同，需自行按下面的格式拼接
					let res = {
						series: [{
							data: this.statistics
						}]
					};
					this.chartData = JSON.parse(JSON.stringify(res));
				}, 500);
			},
		}
	};
</script>
<style lang="scss" scoped>
	.charts-box {
		width: 100%;
		height: 500rpx;
	}

	.result_bg {
		background: url(/static/images/115.png) no-repeat;
		background-size: 100% auto;
		padding: 60rpx 0 0;

		.result_title {
			display: flex;
			align-items: center;
			justify-content: center;

			.result_title_text {
				color: #fff;
				font-size: 32rpx;
				margin: 0 20rpx;
			}

			image {
				width: 155rpx;
				height: 12rpx;
			}
		}

		.result_name {
			display: flex;
			align-items: center;
			justify-content: center;
			margin-top: 24rpx;

			.result_name_1 {
				color: #fff;
				font-size: 20rpx;

				.result_name_1_1 {
					margin-right: 10rpx;
				}
			}

			.result_name_2 {
				width: 2rpx;
				height: 20rpx;
				background: #fff;
				margin: 0 28rpx;
			}
		}

		.result_score {
			display: flex;
			justify-content: center;
			align-items: flex-end;
			margin-top: 65rpx;

			.score_1 {
				color: #fff;
				font-size: 100rpx;
				font-weight: bold;
				margin-right: 5rpx;
			}

			.score_2 {
				color: #fff;
				font-size: 32rpx;
				font-weight: bold;
				transform: translateY(-20rpx);
			}
		}

		.result_tips_1 {
			text-align: center;
			font-size: 20rpx;
			color: #fff;
			margin: 12rpx 0 28rpx;
		}

		.result_tips_2 {
			display: inline-block;
			border: 1px solid #fff;
			padding: 10rpx 65rpx;
			margin-left: 50%;
			transform: translateX(-50%);
			border-radius: 5rpx;

			.stage_1 {
				font-size: 20rpx;
				color: #fff;
			}

			.stage_2 {
				color: #fff;
				font-size: 20rpx;
				font-weight: bold;
				margin: 0 10rpx;
			}

			.stage_3 {
				font-size: 20rpx;
				color: #fff;
			}
		}

		.statistics {
			background: #fff;
			border-radius: 16rpx;
			margin: 65rpx 25rpx 0;
			padding: 45rpx 60rpx 80rpx;

			.test_title {
				display: flex;
				align-items: center;
				padding-bottom: 30rpx;
				border-bottom: 1px solid #eee;

				.test_title_img {
					width: 80rpx;
					height: 80rpx;
					margin-right: 20rpx;

					image {
						width: 100%;
						height: 100%;
					}
				}

				.test_title_view {

					.test_title_view_1 {
						font-size: 25rpx;
						font-weight: bold;
						margin-bottom: 8rpx;
					}

					.test_title_view_2 {
						font-size: 15rpx;
						color: #666;
					}
				}
			}
		}
	}

	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: rgba(248, 248, 248, 1);
		background-size: 100% auto !important;
	}

	.platformMessage_flex_0 {
		background: #fff;
		width: 100%;
		height: 64rpx;
		overflow: hidden;
		z-index: 10;
		top: 0rpx;
		background-size: 100% auto !important;
	}

	.platformMessage_fd0_0_c1_c0 {
		font-size: 25rpx;
		font-weight: 500;
		color: #333333;
		line-height: 64rpx;
	}

	.platformMessage_fd0_0_c0_c0 {
		font-size: 25rpx;
		color: #333;
	}

	.platformMessage_fd0_0_c0 {
		width: 50rpx;
		height: 50rpx;
	}

	.platformMessage_fd0_0 {
		padding: 0rpx 25rpx 0rpx 25rpx;
	}

	.platformMessage_flex_1 {
		// margin: 16rpx 25rpx 16rpx 25rpx;
		// background: #fff;
		// border-radius: 10rpx;
	}

	.platformMessage_fd1_0_c2 {
		font-size: 18rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 25rpx;
	}

	.platformMessage_fd1_0_c1 {
		margin: 10rpx 0rpx 0rpx 0rpx;
		font-size: 18rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #999999;
		line-height: 26rpx;
		// -webkit-line-clamp: 2;
		// overflow: hidden;
		// text-overflow: ellipsis;
		// display: -webkit-box;
		// -webkit-box-orient: vertical;
	}

	.platformMessage_fd1_0_c0 {
		font-size: 20rpx;
		font-family: PingFang SC, PingFang SC;
		font-weight: 400;
		color: #333333;
		// line-height: 45rpx;
		// -webkit-line-clamp: 1;
		// overflow: hidden;
		// text-overflow: ellipsis;
		// display: -webkit-box;
		// -webkit-box-orient: vertical;
	}

	.platformMessage_fd1_0 {
		// background: #fff;
		width: 100%;
		padding: 20rpx 25rpx 20rpx 25rpx;
		border-bottom: 1px solid #eee;
	}
</style>